import * as YvanUI from "yvan-ui-wotu";

const _ = YvanUI.lodash

interface Ref {
}

export default class aliasQuery extends YvanUI.Scope<void, Ref> {

    main = {}

    onRender() {
        window['biz'] = this
    }

    vjson = {
        title: '对齐查询',
        items: [
            {
                view: 'card',
                items: [
                    {
                        view: 'table',
                        idField: 'name1',
                        pagination: false,
                        pageSize: 20,
                        selection: true,
                        columns: [
                            {title: '标准名称', dataIndex: 'name1'},
                            {title: '别名', dataIndex: 'name2'},
                        ],
                        dataSource: {
                            url: '/kg/search/full/align',
                            method: 'post-json',
                            params: {
                                label: "disease"
                            }
                        },
                        onDataSourceAfter: (sender: YvanUI.Table, dataOrgin: any[], raw: any, api: any) => {
                            // raw.pagination = {
                            //     current: api.data.pagination.limitOffset / api.data.pagination.limit + 1,
                            //     total: raw.result.length,
                            //     size: api.data.pagination.limit
                            // }

                            return _.map(raw.result, ([name1, name2]) => {
                                return {
                                    name1, name2
                                }
                            });
                            // return _.map(raw.result.slice(
                            //     api.data.pagination.limitOffset,
                            //     api.data.pagination.limitOffset + api.data.pagination.limit), ([name1, name2]) => {
                            //     return {
                            //         name1, name2
                            //     }
                            // })
                        }
                    }
                ]
            }
        ]
    }
}